%%%% Solution Algorithm for the Representative-Agent Equivalent for the Aiyagari (1994,QJE)                  
function F=steady_exog(y,alpha,beta,delta,gamma,varphi,zbar,hss)
% Assignment of Endogenous Variables as:
% y(1) Capital (k)
% y(2) Consumption (c)
% y(3) Wage (w)
% y(4) Real Interest Rate (r)

k=y(1);
c=y(2);
w=y(3);
r=y(4);

l=zbar*hss; %effective labor (l)

gdp=(k^alpha)*(l^(1-alpha));

F(1)=1-beta*(1+r);                      % Consumption-Investment Optimality Condition (i.e. Euler Equation)
F(2)=gdp-c-delta*k;                     % Aggregate Budget Constraint
F(3)= w-(1-alpha)*((k/l)^alpha);        % Competitive Wage (=MPL)
F(4)= r- (alpha*(l/k)^(1-alpha)-delta); % Competitive Real Interest Rate (=MPK)
